/*
 *  Copyright (C) void Team 2010 Pedro Batista
 * 
 *  http://code.google.com/p/capacitec
 * 
 *  This file is part of capacitec.
 * 
 *  capacitec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  capacitec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with capacitec.  If not, see <http://www.gnu.org/licenses/>.
 */

package entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author pedro
 */
@Entity
@Table(name = "curso", uniqueConstraints = {
	@UniqueConstraint(columnNames = {"id"})})
@NamedQueries({
	@NamedQuery(name = "Curso.findAll", query = "SELECT c FROM Curso c"),
	@NamedQuery(name = "Curso.findById", query = "SELECT c FROM Curso c WHERE c.id = :id"),
	@NamedQuery(name = "Curso.findByNome", query = "SELECT c FROM Curso c WHERE c.nome = :nome"),
	@NamedQuery(name = "Curso.findByCargaHoraria", query = "SELECT c FROM Curso c WHERE c.cargaHoraria = :cargaHoraria")})
public class Curso implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Basic(optional = false)
        @Column(name = "id", nullable = false)
	private Integer id;
	@Basic(optional = false)
        @Column(name = "nome", nullable = false, length = 45)
	private String nome;
	@Basic(optional = false)
        @Column(name = "cargaHoraria", nullable = false)
	private int cargaHoraria;
	@Lob
        @Column(name = "observacoes", length = 65535)
	private String observacoes;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "curso")
	private List<Turma> turmaList;
	@JoinColumn(name = "subPrograma_id", referencedColumnName = "id", nullable = false)
        @ManyToOne(optional = false)
	private SubPrograma subPrograma;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "curso")
	private List<AlunoSubProgramaTurma> alunoSubProgramaTurmaList;

	public Curso() {
	}

	public Curso(Integer id) {
		this.id = id;
	}

	public Curso(Integer id, String nome, int cargaHoraria) {
		this.id = id;
		this.nome = nome;
		this.cargaHoraria = cargaHoraria;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public int getCargaHoraria() {
		return cargaHoraria;
	}

	public void setCargaHoraria(int cargaHoraria) {
		this.cargaHoraria = cargaHoraria;
	}

	public String getObservacoes() {
		return observacoes;
	}

	public void setObservacoes(String observacoes) {
		this.observacoes = observacoes;
	}

	public List<Turma> getTurmaList() {
		return turmaList;
	}

	public void setTurmaList(List<Turma> turmaList) {
		this.turmaList = turmaList;
	}

	public SubPrograma getSubPrograma() {
		return subPrograma;
	}

	public void setSubPrograma(SubPrograma subPrograma) {
		this.subPrograma = subPrograma;
	}

	public List<AlunoSubProgramaTurma> getAlunoSubProgramaTurmaList() {
		return alunoSubProgramaTurmaList;
	}

	public void setAlunoSubProgramaTurmaList(List<AlunoSubProgramaTurma> alunoSubProgramaTurmaList) {
		this.alunoSubProgramaTurmaList = alunoSubProgramaTurmaList;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Curso)) {
			return false;
		}
		Curso other = (Curso) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "entidades.Curso[id=" + id + "]";
	}

}
